<template>
  <div class="side-navbar1-component" :style="componentStyle">
    <div class="sidebar-header" v-if="显示顶部">
      <div class="logo-container">
        <img v-if="Logo图片" :src="Logo图片" alt="Logo" class="logo-image">
        <span v-else class="logo-text">{{ Logo文字 }}</span>
      </div>
    </div>
    
    <div class="sidebar-menu">
      <div 
        v-for="(item, index) in 菜单项目" 
        :key="index"
        class="menu-item"
        :class="{ 'active': index === 0 }"
      >
        <i :class="getIconClass(index)"></i>
        <span class="menu-text">{{ item }}</span>
      </div>
    </div>
    
    <div class="sidebar-footer" v-if="显示底部">
      <div class="user-info">
        <i class="el-icon-user-solid"></i>
        <span>{{ 用户名称 }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SideNavbar1Component',
  componentName: '侧边导航栏1',
  icon: 'el-icon-s-operation',
  defaultProps: {
    背景颜色: '#001529',
    文字颜色: '#ffffff',
    高亮颜色: '#1890ff',
    显示顶部: true,
    Logo文字: 'ADMIN',
    Logo图片: '',
    菜单项目: ['仪表盘', '用户管理', '产品管理', '订单管理', '设置'],
    显示底部: true,
    用户名称: '管理员'
  },
  props: {
    背景颜色: {
      type: String,
      default: '#001529'
    },
    文字颜色: {
      type: String,
      default: '#ffffff'
    },
    高亮颜色: {
      type: String,
      default: '#1890ff'
    },
    显示顶部: {
      type: Boolean,
      default: true
    },
    Logo文字: {
      type: String,
      default: 'ADMIN'
    },
    Logo图片: {
      type: String,
      default: ''
    },
    菜单项目: {
      type: Array,
      default: () => ['仪表盘', '用户管理', '产品管理', '订单管理', '设置']
    },
    显示底部: {
      type: Boolean,
      default: true
    },
    用户名称: {
      type: String,
      default: '管理员'
    }
  },
  methods: {
    getIconClass(index) {
      const icons = [
        'el-icon-s-home',
        'el-icon-user',
        'el-icon-s-goods',
        'el-icon-s-order',
        'el-icon-setting'
      ];
      return icons[index] || 'el-icon-menu';
    }
  },
  computed: {
    componentStyle() {
      return {
        backgroundColor: this.背景颜色,
        color: this.文字颜色,
        width: '100%',
        height: '100%',
        boxSizing: 'border-box'
      };
    }
  }
};
</script>

<style scoped>
.side-navbar1-component {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
}

.sidebar-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-image {
  height: 32px;
  max-width: 80%;
  object-fit: contain;
}

.logo-text {
  font-size: 1.2rem;
  font-weight: bold;
  letter-spacing: 1px;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.menu-item {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s;
}

.menu-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
  background-color: v-bind(高亮颜色);
}

.menu-item i {
  margin-right: 10px;
  font-size: 1.1rem;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
}

.user-info i {
  margin-right: 8px;
}
</style>